package models

import "gorm.io/gorm"

type Novel struct {
	gorm.Model
	Title   string `gorm:"type:varchar(100);unique;not null;comment:小说标题"`
	Author  string `gorm:"type:varchar(30);not null;comment:小说作者"`
	Content string `gorm:"type；longtext;comment:小说内容"`
	Status  int    `gorm:"type:tinyint(1);not null;default:0;comment:状态 0：未审核 1：已审核"`
}

func (n *Novel) Add() error {
	return DB.Create(&n).Error
}
func (n *Novel) List() (novels []Novel, err error) {
	err = DB.Debug().Where("status=1").Find(&novels).Error
	return novels, err
}
func (n *Novel) Del() error {
	return DB.Delete(&n).Error
}
func (n *Novel) Update() error {
	return DB.Updates(&n).Error
}
func (n *Novel) Detail() error {
	return DB.First(&n).Error
}
